﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using HotelManagement.Class;

namespace HotelManagement
{
    public partial class Site1 : System.Web.UI.MasterPage
    {
        string role = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            
            UserAccount us=(UserAccount)Session["object"];
            if (us != null)
            {
                role = us.Role; //role of authenticated user
            }
            
        }

        protected void LinkButton1_Click(object sender, EventArgs e) //Home button
        {
            Response.Redirect("~/UserManagementModule/LoginSuccess.aspx"); 
        }

        protected void LinkButton2_Click(object sender, EventArgs e) //Room Availability button
        {
            Response.Redirect("~/ManageBookingModule.aspx");
        }

        protected void LinkButton3_Click(object sender, EventArgs e) //Housekeeping button
        {
            if (role == "Admin" || role == "Management")
            {
                Response.Redirect("~/ManageHousekeepingAndStaff.aspx"); 
            }
            else {
                ScriptManager.RegisterStartupScript(this, GetType(), "error", "alert('Sorry, you are not the authorized person to access this module!');", true);
                
            }
        }

        protected void LinkButton4_Click(object sender, EventArgs e) //UserManagement button
        {
            if (role == "Admin")
            {
                Response.Redirect("~/UserManagementModule/AdminMenu.aspx");
            }
            else {
                ScriptManager.RegisterStartupScript(this, GetType(), "error", "alert('Sorry, you are not the authorized person to access this module!');", true);
               
            }
        }

        protected void LinkButton5_Click(object sender, EventArgs e) //Logout button
        {
            FormsAuthentication.SignOut();
            Response.Redirect(FormsAuthentication.LoginUrl);
        }

       


    }
}